﻿<%--
    Document   : manageDish
    Created on : Feb 6, 2013, 1:06:59 PM
    Author     : Vrety
--%>

<%@page pageEncoding="UTF-8" contentType='text/html;charset=UTF-8'%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%> 
<script language='javascript' src="js/jquery.js" type="text/javascript"></script>
<style media="all" type="text/css">

</style>
<script src="js/displayTagAjax.js">
</script>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Manage Dish Page</title>
        <script type="text/javascript" >

            function exportmasterfile()
            {                  
                var url='${pageContext.request.contextPath}'+'/xml/Dishes.pdf';
                window.open(url,'Download');
                //TheNewWin = window.open(url);
                //alert(url);
            }
            function onload()
            {
                if(sessionScope.dishResults != null)
                {
                    document.getElementById('btnSearch').click();
                }
            }
        </script>
    </head>
    <body onload="onload()" >

        <jsp:include page="adminHeader.jsp"/>
        <form action="ControllerServlet" method="POST">
            Dish Name: <input type="text" name="txtDishName" value="" />
            <input type="submit" value="SearchDish" name="btnAction" id="btnSearch"  />
            <input type="submit" value="CreatePDF" name="btnAction"  />
        </form>
        
       <!-- <input style="" type="button" value="AddDish" onClick="self.location='addDish.jsp'" /> -->
        <div id="ajxDspId">
            <c:choose>
                <c:when test="${empty sessionScope.dishResults }">
                    <h2>Dish not found</h2>
                </c:when>
                <c:otherwise>
                    <display:table name="sessionScope.dishResults" pagesize="10"
                                   export="false" sort="list" id="dispTables"   >
                        <display:column property="dishName" title="Dish Name"
                                        sortable="true" headerClass="sortable"/>
                        <display:column property="calories" title="Calories"
                                        sortable="true" headerClass="Image" />
                        <display:column title="Image" sortable="true"
                                        headerClass="sortable" >
                            <img alt=""  src="${pageContext.request.contextPath}/images/dish/${dispTables.imageURL}" width="200" height="200"/>
                        </display:column>

                    </display:table>

                </c:otherwise>
            </c:choose>
        </div>
    </body>
</html>
